package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppMaterialInventoryAlert;
import com.ep.modules.app.service.AppMaterialInventoryAlertService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/material_inventory_alert")
public class AppMaterialInventoryAlertController {
    @Autowired
    private AppMaterialInventoryAlertService appMaterialInventoryAlertService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appMaterialInventoryAlertService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppMaterialInventoryAlert appmaterialinventoryalert = appMaterialInventoryAlertService.getById(id);
        return R.ok().put("appmaterialinventoryalert", appmaterialinventoryalert);
    }

    @SysLog("保存AppMaterialInventoryAlert")
    @PostMapping("/save")
    public R save(@RequestBody AppMaterialInventoryAlert appmaterialinventoryalert) {
        ValidatorUtils.validateEntity(appmaterialinventoryalert);
        appMaterialInventoryAlertService.save(appmaterialinventoryalert);
        return R.ok();
    }

    @SysLog("修改AppMaterialInventoryAlert")
    @PostMapping("/update")
    public R update(@RequestBody AppMaterialInventoryAlert appmaterialinventoryalert) {
        ValidatorUtils.validateEntity(appmaterialinventoryalert);
        appMaterialInventoryAlertService.update(appmaterialinventoryalert);
        return R.ok();
    }

    @SysLog("删除AppMaterialInventoryAlert")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appMaterialInventoryAlertService.deleteBatch(ids);
        return R.ok();
    }
}